<?php
namespace app\index\controller;
use think\Controller;
use think\Db;
use think\Session;
class Company extends Controller
{
    public function index()
    {
       
        $gs = Db::table('company')->where('company_status',0)->order('company_id desc')->paginate(5);
        
        // dump($xj);
        // exit;
        $this->assign("gs",$gs);
        $page = $gs->render();
        // dump($page);
        // exit;
        $this->assign('page', $page);
        $gw1 = Db::table('position')
        ->alias('a')
        ->join('company c','c.company_id = a.company_id')
        ->where('position_status',0)
        ->order('position_id desc')
        ->limit(3)
    ->select();
        // dump($gw1);
        // exit;
        
        $this->assign("gw1",$gw1);
       return $this->fetch();
    }

    public function gsdetails($company_id)
    {
        $a = Session::has('user_id');
        if($a == null)
        {
            $gs = Db::table('company')->where('company_status',0)->where('company_id',$company_id)->order('company_id desc')->select();
        
        // dump($xj);
        // exit;
        $this->assign("gs",$gs);
        $gw = Db::table('position')
        ->where('company_id',$company_id)
        ->where('position_status',0)
        ->order('position_id desc')
        ->select();
        
        // dump($xj);
        // exit;
        $this->assign("gw",$gw);
            $jl = 0;
            $this->assign("jl",$jl);
            return $this->fetch();
        }
        else
        {
            $gs = Db::table('company')->where('company_status',0)->where('company_id',$company_id)->order('company_id desc')->select();
        
        // dump($xj);
        // exit;
        $this->assign("gs",$gs);
        $gw = Db::table('position')
        ->where('company_id',$company_id)
        ->where('position_status',0)
        ->order('position_id desc')
        ->select();
        
        // dump($xj);
        // exit;
        $this->assign("gw",$gw);
        $user_id = Session::get("user_id");
        $jl = Db::table('resume')
        ->where('user_id',$user_id)
        ->where('resume_status',0)
        ->select();
        // dump($jl);
        // exit;
       $this->assign("jl",$jl);
         return $this->fetch();
        }
       
        
    }
}
